home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 1 / ETO Development Tools 1.iso / Tools - Objects / MacApp / Unsupported Samples / CRC Cards / Source / UCard.inc1.p < prev    next >
Encoding:
Text File  |  1990-07-11  |  24.8 KB  |  1,036 lines  |  [TEXT/MPS ]

  1. (*********************)
  2. (* methods for TCard *)
  3. (*********************)
  4.  
  5. {$S ARes}
  6. FUNCTION TCard.GetDocument: TDesignDocument;
  7.  
  8.     BEGIN
  9.         GetDocument:= fDocument;
  10.     END;   {TCard.GetDocument}
  11.  
  12. {$S ARes}
  13. PROCEDURE TCard.SetDocument(theDocument: TDesignDocument);
  14.  
  15.     BEGIN
  16.         fDocument:= theDocument;
  17.     END;   {TCard.SetDocument}
  18.  
  19. {$S ARes}
  20. FUNCTION TCard.GetDesignView: TDesignView;
  21.  
  22.     BEGIN
  23.         GetDesignView:= fDesignView;
  24.     END;   {TCard.GetDesignView}
  25.  
  26. {$S ARes}
  27. PROCEDURE TCard.SetDesignView(theDesignView: TDesignView);
  28.  
  29.     BEGIN
  30.         fDesignView:= theDesignView;
  31.     END;   {TCard.SetDesignView}
  32.  
  33. {$S ARes}
  34. FUNCTION TCard.GetTextHandler: TTextHandler;
  35.  
  36.     BEGIN
  37.         GetTextHandler:= fTextHandler;
  38.     END;   {TCard.GetTextHandler}
  39.  
  40. {$S ARes}
  41. PROCEDURE TCard.SetTextHandler(theTextHandler: TTextHandler);
  42.  
  43.     BEGIN
  44.         fTextHandler:= theTextHandler;
  45.     END;   {TCard.SetTextHandler}
  46.  
  47. {$S ARes}
  48. FUNCTION TCard.GetEditView: TEditView;
  49.  
  50.     BEGIN
  51.         GetEditView:= fEditView;
  52.     END;   {TCard.GetEditView}
  53.  
  54. {$S ARes}
  55. PROCEDURE TCard.SetEditView(theEditView: TEditView);
  56.  
  57.     BEGIN
  58.         fEditView:= theEditView;
  59.     END;   {TCard.SetEditView}
  60.     
  61. {$S ARes}
  62. FUNCTION TCard.GetTheClass: TItem;
  63.  
  64.     BEGIN
  65.         GetTheClass:= fClassName;
  66.     END;   {TCard.GetTheClass}
  67.  
  68. {$S ARes}
  69. PROCEDURE TCard.SetTheClass(anItem: TItem);
  70.  
  71.     BEGIN
  72.         fClassName:= anItem;
  73.     END;   {TCard.SetTheClass}
  74.     
  75. {$S ARes}
  76. FUNCTION TCard.GetTheSuperClass: TItem;
  77.  
  78.     BEGIN
  79.         GetTheSuperClass:= fSuperClass;
  80.     END;   {TCard.GetTheSuperClass}
  81.  
  82. {$S ARes}
  83. PROCEDURE TCard.SetTheSuperClass(anItem: TItem);
  84.  
  85.     BEGIN
  86.         fSuperClass:= anItem;
  87.     END;   {TCard.SetTheSuperClass}
  88.  
  89. {$S ARes}
  90. FUNCTION TCard.GetNumFields: ArrayIndex;
  91.  
  92.     BEGIN
  93.         GetNumFields:= fFieldList.GetSize;
  94.     END;   {TCard.GetNumFields}
  95.  
  96. {$S ARes}
  97. FUNCTION TCard.GetNumMethods: ArrayIndex;
  98.  
  99.     BEGIN
  100.         GetNumMethods:= fMethodList.GetSize;
  101.     END;   {TCard.GetNumMethods}
  102.  
  103. {$S ARes}
  104. FUNCTION TCard.GetNumCollaborators: ArrayIndex;
  105.  
  106.     BEGIN
  107.         GetNumCollaborators:= fCollaboratorList.GetSize;
  108.     END;   {TCard.GetNumCollaborators}
  109.  
  110. {$S ADoCommand}
  111. PROCEDURE TCard.ChangeClass(theName: str255);
  112.     VAR 
  113.         theOldName: Str255;
  114.     BEGIN
  115.         theOldName:= SELF.GetTheClass.GetTheName;
  116.         fClassName.SetTheName(theName);  {this filters out bad chars & adds the prefix}
  117.         theName:= fClassName.GetTheName;
  118.         fSimpleCardView.ChangeClassName(theName);
  119.         fEditView.ChangeClassName(theName);
  120.         SELF.GetDocument.ChangeNameInObjectLists(theOldName, theName);
  121.     END;    {TCard.ChangeClass}
  122.  
  123. {$S ADoCommand}
  124. PROCEDURE TCard.ChangeSuperClass(theName: str255);
  125.  
  126.     BEGIN
  127.         fSuperClass.SetTheName(theName);
  128.         theName:= fSuperClass.GetTheName;
  129.         fSimpleCardView.ChangeSuperClassName(theName);
  130.         fEditView.ChangeSuperClassName(theName);
  131.     END;    {TCard.ChangeSuperClass}
  132.  
  133. {$S ADoCommand}
  134. PROCEDURE TCard.ChangeField(theFieldItem: TFieldItem; 
  135.                                                         theName: Str255; theType: Str255);
  136.  
  137. VAR
  138.     theItem: INTEGER;
  139.     theFieldTextListView: TFieldTextListView;
  140.     
  141. BEGIN
  142.     theFieldItem.SetTheName(theName);
  143.     theFieldItem.SetItemType(theType);
  144.     theItem:=SELF.GetIndexOfField(theFieldItem);
  145.     theFieldTextListView:=fEditView.fFieldTextListView;
  146.     theFieldTextListView.InvalidateItem(theItem);
  147.     SELF.GetEditView.DeselectFieldTextListView;
  148. END; {TCard.ChangeField}
  149.  
  150. {$S ADoCommand}
  151. PROCEDURE TCard.ChangeMethod(theMethodItem: TMethodItem;
  152.                                                         theName: Str255; IsOverride: Boolean);
  153. VAR
  154.     theItem: INTEGER;
  155.     theMethodTextListView: TMethodTextListView;
  156.     
  157. BEGIN
  158.     theMethodItem.SetTheName(theName);
  159.     theMethodItem.SetOVERRIDE(IsOverride);
  160.     theItem:=SELF.GetIndexOfMethod(theMethodItem);
  161.     theMethodTextListView:=fEditView.fMethodTextListView;
  162.     theMethodTextListView.InvalidateItem(theItem);
  163.     SELF.GetEditView.DeselectMethodTextListView;
  164. END; {TCard.ChangeMethod}
  165.  
  166. {$S ADoCommand}
  167. PROCEDURE TCard.ChangeCollaborator(theCollaboratorItem: TCollaboratorItem; 
  168.                                                                         theName: Str255);        
  169.  
  170. VAR
  171.     theItem: INTEGER;
  172.     theCollaboratorTextListView: TCollaboratorTextListView;
  173.     
  174. BEGIN
  175.     theCollaboratorItem.SetTheName(theName);
  176.     theItem:=SELF.GetIndexOfCollaborator(theCollaboratorItem);
  177.     theCollaboratorTextListView:=fEditView.fCollaboratorTextListView;
  178.     theCollaboratorTextListView.InvalidateItem(theItem);
  179.     SELF.GetEditView.DeselectCollaboratorTextListView;
  180. END; {TCard.ChangeCollaborator}
  181.  
  182. {$S ARes}
  183. PROCEDURE TCard.CreateSimpleView(theDesignView: TDesignView; theDesignDoc: TDesignDocument);
  184.  
  185.     VAR
  186.         aSimpleView: TSimpleView;
  187.         subviewOffset: VPoint;
  188.         theSimpleViewList: TList;
  189.         anItem: TItem;
  190.         aString: str255;
  191.  
  192.     BEGIN
  193.         {find the simple view list}
  194.         theSimpleViewList:= theDesignView.GetSimpleViewList;
  195.         
  196.         {create the Simple card's view}
  197.         subviewOffset:= SELF.GetLocation;
  198.         aSimpleView:= TSimpleView(theDesignView.DoCreateViews(theDesignDoc, theDesignView, 
  199.                                                                                         kSimpleViewID, subviewOffset));
  200.         aSimpleView.SetCard(SELF);
  201.         
  202.         {initialize the simple view and insert it into the list}
  203.         aSimpleView.ISimpleView;
  204.         anItem:= SELF.GetTheClass;
  205.         aString:= anItem.GetTheItem;
  206.         aSimpleView.ChangeClassName(aString);
  207.         anItem:= SELF.GetTheSuperClass;
  208.         aString:= anItem.GetTheItem;
  209.         aSimpleView.ChangeSuperClassName(aString);
  210.         SELF.SetSimpleView(aSimpleView);
  211.         theSimpleViewList.InsertLast(aSimpleView);
  212.         
  213.         theDesignView.AdjustSize;
  214.         aSimpleView.ForceRedraw;
  215.     END;   {TCard.CreateSimpleView}
  216.     
  217. {$S ARes}
  218. PROCEDURE TCard.DeleteSimpleView;
  219.     
  220.     VAR
  221.         theDesignView: TDesignView;
  222.         theSimpleView: TSimpleView;
  223.         theSimpleViewList: TList;
  224.         
  225.     BEGIN
  226.         theDesignView:= SELF.GetDesignView;
  227.         theSimpleView:= SELF.GetSimpleView;
  228.         theSimpleViewList:= theDesignView.GetSimpleViewList;
  229.         theSimpleViewList.Delete(theSimpleView);
  230.         theDesignView.RemoveSubView(theSimpleView);
  231.         theSimpleView.Free;
  232.     END;    {TCard.DeleteSimpleView}
  233.     
  234. {$S ARes}
  235. PROCEDURE TCard.DeleteEditView;
  236.  
  237.     VAR
  238.         theWindow: TWindow;
  239.  
  240.     BEGIN
  241.         IF fEditView <> NIL THEN
  242.             BEGIN
  243.                 theWindow:= fEditView.GetWindow;
  244.                 theWindow.Close;
  245.                 theWindow.Free;
  246.                 SELF.SetEditView(NIL);
  247.             END;
  248.     END;    {TCard.DeleteEditView}
  249.     
  250. {$S ARes}
  251. FUNCTION TCard.GetSimpleView: TSimpleView;
  252.  
  253.     BEGIN
  254.         GetSimpleView:= fSimpleCardView;
  255.     END;   {TCard.GetSimpleView}
  256.     
  257. {$S ARes}
  258. PROCEDURE TCard.SetSimpleView(aSimpleView: TSimpleView);
  259.  
  260.     BEGIN
  261.         fSimpleCardView:= aSimpleView;
  262.     END;   {TCard.SetSimpleView}
  263.     
  264. {$S ARes}
  265. FUNCTION TCard.GetLocation: VPoint;
  266.  
  267.     BEGIN
  268.         GetLocation:= fLocation;
  269.     END;    {TCard.GetLocation}
  270.     
  271. {$S ARes}
  272. PROCEDURE TCard.SetLocation(theLocation: VPoint);
  273.  
  274.     BEGIN
  275.         fLocation:= theLocation;
  276.     END;    {TCard.SetLocation}
  277.         
  278. {$S ARes}
  279. FUNCTION TCard.GetFields: TMyList;
  280.     BEGIN
  281.         GetFields:= fFieldList;
  282.     END;    {TCard.GetFields}
  283.     
  284. {$S ARes}
  285. PROCEDURE TCard.SetFields(aFieldList: TMyList);
  286.  
  287.     BEGIN
  288.         fFieldList:= aFieldList;
  289.     END;    {TCard.SetFields}
  290.  
  291. {$S ARes}
  292. FUNCTION TCard.GetMethods: TMyMethodList;
  293.     BEGIN
  294.         GetMethods:= fMethodList;
  295.     END;    {TCard.GetMethods}
  296.     
  297. {$S ARes}
  298. PROCEDURE TCard.SetMethods(aMethodList: TMyMethodList);
  299.  
  300.     BEGIN
  301.         fMethodList:= aMethodList;
  302.     END;    {TCard.SetMethods}
  303.  
  304. {$S ARes}
  305. FUNCTION TCard.GetCollaborators: TMyList;
  306.     BEGIN
  307.         GetCollaborators:= fCollaboratorList;
  308.     END;    {TCard.GetCollaborators}
  309.     
  310. {$S ARes}
  311. PROCEDURE TCard.SetCollaborators(aCollaboratorList: TMyList);
  312.  
  313.     BEGIN
  314.         fCollaboratorList:= aCollaboratorList;
  315.     END;    {TCard.SetCollaborators}
  316.  
  317. {$S ADoCommand}
  318. PROCEDURE TCard.AddCardToObjectLists(theCardToAdd: TCard);
  319.  
  320. VAR
  321.     theEditView: TEditView;
  322.     
  323. BEGIN
  324.     theEditView:=SELF.GetEditView;
  325.     IF theEditView<>NIL THEN 
  326.         theEditView.AddCardToObjectLists(theCardToAdd);
  327. END;
  328.  
  329. {$S ADoCommand}
  330. PROCEDURE TCard.RemoveCardFromObjectLists(theCardToRemove: TCard);
  331.  
  332. VAR
  333.     theEditView: TEditView;
  334.     
  335. BEGIN
  336.     theEditView:=SELF.GetEditView;
  337.     IF theEditView<>NIL THEN 
  338.         theEditView.RemoveCardFromObjectLists(theCardToRemove);
  339. END;
  340.  
  341. {$S ADoCommand}
  342. PROCEDURE TCard.ChangeNameInObjectLists(theOldName, theNewName: Str255);
  343.  
  344. VAR
  345.     theEditView: TEditView;
  346.     theCollaborators: TMyList;
  347.     theSuperClass: Str255;
  348.     
  349.         PROCEDURE ChangeCollaboratorName(aCollaborator: TCollaboratorItem);
  350.         
  351.         VAR
  352.             theGetAccessor: TGetAccessorItem;
  353.             theSetAccessor: TSetAccessorItem;
  354.             theName, theCorrectName: Str255;
  355.             
  356.         BEGIN
  357.             theName:=aCollaborator.GetTheItem;
  358.             IF theName=theOldName THEN
  359.                 BEGIN
  360.                     SELF.ChangeCollaborator(aCollaborator,theNewName);
  361.                     theCorrectName:=aCollaborator.GetTheName;
  362.                     aCollaborator.GetAccessors(theGetAccessor,theSetAccessor);
  363.                     IF theGetAccessor<>NIL THEN
  364.                         SELF.ChangeMethod(theGetAccessor,theCorrectName,FALSE);
  365.                     IF theSetAccessor<>NIL THEN
  366.                         SELF.ChangeMethod(theSetAccessor,theCorrectName,FALSE);
  367.                 END;
  368.         END;
  369.         
  370. BEGIN
  371.     theEditView:=SELF.GetEditView;
  372.     IF theEditView<>NIL THEN 
  373.         theEditView.ChangeNameInObjectLists(theOldName, theNewName);
  374.     theCollaborators:= SELF.GetCollaborators;
  375.     theCollaborators.Each(ChangeCollaboratorName);
  376.     theSuperClass:= SELF.GetTheSuperClass.GetTheItem;
  377.     IF theSuperClass=theOldName THEN
  378.         BEGIN
  379.             SELF.ChangeSuperClass(theNewName);
  380.             IF theEditView<>NIL THEN
  381.                 theEditView.DoSelectEditText(theEditView.fSuperClassNameItem, TRUE);
  382.         END;
  383.     
  384. END;
  385.  
  386. {$S AOpen}
  387. PROCEDURE TCard.ICard(theDesignDoc: TDesignDocument; theLocation: VPoint);
  388.  
  389.     VAR
  390.         aName: TItem;
  391.         aList: TMyList;
  392.         aMethodList: TMyMethodList;
  393.         theNumber: str255;
  394.         theDesignView: TDesignView;
  395.         
  396.     BEGIN
  397.         NEW(aName);
  398.         FailNil(aName);
  399.         theNumber:= theDesignDoc.GetNumCardsStr;
  400.         aName.IItem(SELF, Concat(kStartingClass, theNumber));
  401.         SELF.SetTheClass(aName);
  402.         
  403.         NEW(aName);
  404.         FailNil(aName);
  405.         aName.IItem(SELF, kStartingSuperClass);
  406.         SELF.SetTheSuperClass(aName);
  407.         
  408.         SELF.SetDocument(theDesignDoc);
  409.         theDesignView:= theDesignDoc.GetDesignView;
  410.         SELF.SetDesignView(theDesignView);
  411.         SELF.SetLocation(theLocation);
  412.         
  413.         SELF.SetTextHandler(theDesignDoc.GetTextHandler);
  414.         
  415.         SELF.SetEditView(NIL);
  416.         
  417.         NEW(aList);
  418.         FailNIL(aList);
  419.         aList.IList;
  420.         SELF.SetFields(aList);
  421.         
  422.         NEW(aMethodList);
  423.         FailNIL(aMethodList);
  424.         aMethodList.IList;
  425.         SELF.SetMethods(aMethodList);
  426.         
  427.         NEW(aList);
  428.         FailNIL(aList);
  429.         aList.IList;
  430.         SELF.SetCollaborators(aList);
  431.         
  432.         SELF.SetEditView(NIL);
  433.         SELF.SetSimpleView(NIL);
  434.     END;   {TCard.ICard}
  435.                     
  436. {$S ADoCommand}
  437. FUNCTION TCard.FieldPresent(theField: TFieldItem): boolean;
  438.  
  439.     VAR
  440.         theIndex: ArrayIndex;
  441.         
  442.     BEGIN
  443.         theIndex:= fFieldList.GetEqualItemNo(theField);
  444.         IF theIndex = kNotFound THEN
  445.             FieldPresent:= false
  446.         ELSE
  447.             FieldPresent:= true;
  448.     END;   {TCard.FieldPresent}
  449.                     
  450. {$S ADoCommand}
  451. PROCEDURE TCard.AddFieldAtIndex(theField: TFieldItem; theIndex: ArrayIndex);
  452.     
  453.     BEGIN
  454.         IF theIndex <= fFieldList.GetSize THEN
  455.             BEGIN
  456.                 fFieldList.InsertBefore(theIndex, theField);
  457.                 IF fEditView <> NIL THEN
  458.                     fEditView.AddField(theIndex);
  459.             END
  460.         ELSE
  461.             SELF.AddField(theField);
  462.     END;    {TCard.AddFieldAtIndex}
  463.     
  464. {$S ARes}
  465. FUNCTION TCard.GetIndexOfField(theField: TFieldItem): ArrayIndex;
  466.     
  467.     BEGIN
  468.         IF theField <> NIL THEN
  469.             GetIndexOfField:= fFieldList.GetSameItemNo(theField)
  470.         ELSE
  471.             GetIndexOfField:= kNotFound;
  472.     END;    {TCard.GetIndexOfField}
  473.                     
  474. {$S ARes}
  475. FUNCTION TCard.GetFieldItemAtIndex(theIndex: ArrayIndex): TFieldItem;
  476.     
  477.     BEGIN
  478.         GetFieldItemAtIndex:= TFieldItem(fFieldList.At(theIndex));
  479.     END;    {TCard.GetFieldItemAtIndex}
  480.                     
  481. {$S ADoCommand}
  482. PROCEDURE TCard.AddMethodAtIndex(theMethod: TMethodItem; theIndex: ArrayIndex);
  483.     
  484.     BEGIN
  485.         IF theIndex <= fMethodList.GetSize THEN
  486.             BEGIN
  487.                 fMethodList.InsertBefore(theIndex, theMethod);
  488.                 IF fEditView <> NIL THEN
  489.                     fEditView.AddMethod(theIndex);
  490.             END
  491.         ELSE
  492.             SELF.AddMethod(theMethod);
  493.     END;    {TCard.AddCollaboratorAtIndex}
  494.     
  495. {$S ARes}
  496. FUNCTION TCard.GetMethodItemAtIndex(theIndex: ArrayIndex): TMethodItem;
  497.     
  498.     BEGIN
  499.         GetMethodItemAtIndex:= TMethodItem(fMethodList.At(theIndex));
  500.     END;    {TCard.GetMethodItemAtIndex}
  501.     
  502. {$S ARes}
  503. FUNCTION TCard.GetIndexOfMethod(theMethod: TMethodItem): ArrayIndex;
  504.     
  505.     BEGIN
  506.         IF theMethod <> NIL THEN
  507.             GetIndexOfMethod:= fMethodList.GetSameItemNo(theMethod)
  508.         ELSE
  509.             GetIndexOfMethod:= kNotFound;
  510.     END;    {TCard.GetIndexOfMethod}
  511.                     
  512. {$S ADoCommand}
  513. PROCEDURE TCard.AddCollaboratorAtIndex(theCollaborator: TCollaboratorItem; 
  514.                                                                                 theIndex: ArrayIndex);
  515.     
  516.     BEGIN
  517.         IF theIndex <= fCollaboratorList.GetSize THEN
  518.             BEGIN
  519.                 fCollaboratorList.InsertBefore(theIndex, theCollaborator);
  520.                 IF fEditView <> NIL THEN
  521.                     fEditView.AddCollaborator(theIndex);
  522.             END
  523.         ELSE
  524.             SELF.AddCollaborator(theCollaborator);
  525.     END;    {TCard.AddCollaboratorAtIndex}
  526.     
  527. {$S ARes}
  528. FUNCTION TCard.GetIndexOfCollaborator(theCollaborator: TCollaboratorItem): ArrayIndex;
  529.     
  530.     BEGIN
  531.         IF theCollaborator <> NIL THEN
  532.             GetIndexOfCollaborator:= fCollaboratorList.GetSameItemNo(theCollaborator)
  533.         ELSE
  534.             GetIndexOfCollaborator:= kNotFound;
  535.     END;    {TCard.GetIndexOfCollaborator}
  536.                     
  537. {$S ARes}
  538. FUNCTION TCard.GetCollaboratorItemAtIndex(theIndex: ArrayIndex): TCollaboratorItem;
  539.     
  540.     BEGIN
  541.         GetCollaboratorItemAtIndex:= TCollaboratorItem(fCollaboratorList.At(theIndex));
  542.     END;    {TCard.GetCollaboratorItemAtIndex}
  543.     
  544. {$S ARes}
  545. PROCEDURE TCard.AddField(theField: TFieldItem);
  546.  
  547.     BEGIN
  548.         fFieldList.InsertLast(theField);
  549.         IF fEditView <> NIL THEN
  550.             fEditView.AddFieldLast;
  551.         IF (fFieldList.GetSize = 1) AND (fCollaboratorList.GetSize = 0) THEN
  552.             SELF.AddFieldsMethod;
  553.     END;    {TCard.AddField}
  554.     
  555. {$S ARes}
  556. PROCEDURE TCard.AddMethod(theMethod: TMethodItem);
  557.  
  558.     BEGIN
  559.         fMethodList.InsertLast(theMethod);
  560.         IF fEditView <> NIL THEN
  561.             fEditView.AddMethodLast;
  562.     END;    {TCard.AddMethod}
  563.     
  564. {$S ARes}
  565. PROCEDURE TCard.AddCollaborator(theCollaborator: TCollaboratorItem);
  566.  
  567.     BEGIN
  568.         fCollaboratorList.InsertLast(theCollaborator);
  569.         IF fEditView <> NIL THEN
  570.             fEditView.AddCollaboratorLast;
  571.         IF (fFieldList.GetSize = 0) AND (fCollaboratorList.GetSize = 1) THEN
  572.             SELF.AddFieldsMethod;
  573.     END;    {TCard.AddCollaborator}
  574.     
  575. {$S ARes}
  576. PROCEDURE TCard.AddFieldsMethod;
  577.  
  578.     VAR
  579.         aFieldMethodItem: TFieldsMethodItem;
  580.  
  581.     BEGIN
  582.         NEW(aFieldMethodItem);
  583.         FailNIL(aFieldMethodItem);
  584.         aFieldMethodItem.IMethodItem(SELF, 'Fields', kOVERRIDE);
  585.         SELF.AddMethod(aFieldMethodItem);
  586.     END;    {TCard.AddFieldsMethod}
  587.     
  588. {$S ARes}
  589. PROCEDURE TCard.DeleteField(theField: TFieldItem);
  590.     
  591.     VAR
  592.         theIndex: ArrayIndex;
  593.         theFieldsMethodItem: TMethodItem;
  594.  
  595.     BEGIN
  596.         IF theField <> NIL THEN
  597.             BEGIN
  598.                 theIndex:= fFieldList.GetEqualItemNo(theField);
  599.                 fFieldList.Delete(theField);
  600.                 IF fEditView <> NIL THEN
  601.                     fEditView.DeleteField(theIndex);
  602.                 IF (fFieldList.GetSize = kNoItems) AND (fCollaboratorList.GetSize = kNoItems) THEN
  603.                     BEGIN
  604.                         theFieldsMethodItem:= fMethodList.FindFieldsMethod;
  605.                         IF theFieldsMethodItem <> NIL THEN
  606.                             BEGIN
  607.                                 SELF.DeleteMethod(theFieldsMethodItem);
  608.                                 theFieldsMethodItem.Free;
  609.                             END;
  610.                     END;
  611.             END;
  612.     END;    {TCard.DeleteField}
  613.     
  614. {$S ARes}
  615. PROCEDURE TCard.DeleteMethod(theMethod: TMethodItem);
  616.     
  617.     VAR
  618.         theIndex: ArrayIndex;
  619.  
  620.     BEGIN
  621.         IF theMethod <> NIL THEN
  622.             BEGIN
  623.                 theIndex:= fMethodList.GetEqualItemNo(theMethod);
  624.                 fMethodList.Delete(theMethod);
  625.                 IF fEditView <> NIL THEN
  626.                     fEditView.DeleteMethod(theIndex);
  627.             END;
  628.     END;    {TCard.DeleteMethod}
  629.     
  630. {$S ARes}
  631. PROCEDURE TCard.DeleteCollaborator(theCollaborator: TCollaboratorItem);
  632.     
  633.     VAR
  634.         theIndex: ArrayIndex;
  635.         theFieldsMethodItem: TMethodItem;
  636.  
  637.     BEGIN
  638.         IF theCollaborator <> NIL THEN
  639.             BEGIN
  640.                 theIndex:= fCollaboratorList.GetEqualItemNo(theCollaborator);
  641.                 fCollaboratorList.Delete(TheCollaborator);
  642.                 IF fEditView <> NIL THEN
  643.                     fEditView.DeleteCollaborator(theIndex);
  644.                 IF (fFieldList.GetSize = kNoItems) AND (fCollaboratorList.GetSize = kNoItems) THEN
  645.                     BEGIN
  646.                         theFieldsMethodItem:= fMethodList.FindFieldsMethod;
  647.                         IF theFieldsMethodItem <> NIL THEN
  648.                             SELF.DeleteMethod(theFieldsMethodItem);
  649.                     END;
  650.             END;
  651.     END;    {TCard.DeleteCollaborator}
  652.     
  653. {$S ARes}
  654. PROCEDURE TCard.WriteFieldInterface(theTEView: TMyTEView);
  655.  
  656.     PROCEDURE WriteTheDeclarations(theItem: TItem);
  657.     
  658.         BEGIN
  659.             theItem.WriteDeclaration(theTEView);
  660.         END;
  661.  
  662. BEGIN
  663.     IF fFieldList.GetSize > kNoItems THEN
  664.         BEGIN
  665.             theTEView.WriteToMyTEView(fTextHandler.GetFieldsInterfaceStr);
  666.             fFieldList.Each(WriteTheDeclarations);
  667.             theTEView.WriteEndOfLine;
  668.         END;
  669. END; {TCard.WriteFieldInterface}
  670.  
  671.  
  672. {$S ARes}
  673. PROCEDURE TCard.WriteMethodInterface(theTEView: TMyTEView);
  674.  
  675.     PROCEDURE WriteTheDeclarations(theItem: TItem);
  676.     
  677.         BEGIN
  678.             theItem.WriteDeclaration(theTEView);
  679.         END;
  680.  
  681. BEGIN
  682.     IF fMethodList.GetSize > kNoItems THEN
  683.         BEGIN
  684.             theTEView.WriteToMyTEView(fTextHandler.GetMethodsInterfaceStr);
  685.             fMethodList.Each(WriteTheDeclarations);
  686.             theTEView.WriteEndOfLine;
  687.         END;
  688. END; {TCard.WriteMethodInterface}
  689.  
  690.  
  691. {$S ARes}
  692. PROCEDURE TCard.WriteCollaboratorInterface(theTEView: TMyTEView);
  693.  
  694.     PROCEDURE WriteTheDeclarations(theItem: TItem);
  695.     
  696.         BEGIN
  697.             theItem.WriteDeclaration(theTEView);
  698.         END;
  699.  
  700. BEGIN
  701.     IF fCollaboratorList.GetSize > kNoItems THEN
  702.         BEGIN
  703.             theTEView.WriteToMyTEView(fTextHandler.GetCollaboratorsInterfaceStr);
  704.             fCollaboratorList.Each(WriteTheDeclarations);
  705.             theTEView.WriteEndOfLine;
  706.         END;
  707. END; {TCard.WriteCollaboratorInterface}
  708.  
  709. {$S ARes}
  710. PROCEDURE TCard.WriteInlineProcedures(theTEView: TMyTEView);
  711.  
  712.     PROCEDURE WriteTheInlineProcedures(theMethodItem: TMethodItem);
  713.     
  714.         BEGIN
  715.             theMethodItem.WriteInlineProcedures(theTEView);
  716.         END;
  717.  
  718. BEGIN
  719.     IF fMethodList.GetSize > kNoItems THEN
  720.         BEGIN
  721.             fMethodList.Each(WriteTheInlineProcedures);
  722.         END;
  723. END; {TCard.WriteInlineProcedures}
  724.  
  725. {$S ARes}
  726. PROCEDURE TCard.WriteFwdClassDecl(theTEView: TMyTEView);
  727.  
  728. BEGIN
  729.     theTEView.WriteToMyTEView(fTextHandler.GetFwdClassDeclStr(SELF));
  730. END; {TCard.WriteFwdClassDecl}
  731.  
  732.  
  733. {$S ARes}
  734. PROCEDURE TCard.WriteInterface(theTEView: TMyTEView);
  735.  
  736.     BEGIN
  737.         theTEView.WriteToMyTEView(fTextHandler.GetTypeDefStr(SELF));
  738.         CASE fTextHandler.GetLanguage OF
  739.             kInPascal :    
  740.                 BEGIN
  741.                     SELF.WriteFieldInterface(theTEView);
  742.                     SELF.WriteCollaboratorInterface(theTEView);
  743.                     SELF.WriteMethodInterface(theTEView);
  744.                     theTEView.WriteToMyTEView(fTextHandler.GetEndOfTypeDefStr);
  745.                 END;
  746.             kInCPP :
  747.                 BEGIN
  748.                     SELF.WriteMethodInterface(theTEView);
  749.                     SELF.WriteCollaboratorInterface(theTEView);
  750.                     SELF.WriteFieldInterface(theTEView);
  751.                     theTEView.WriteToMyTEView(fTextHandler.GetEndOfTypeDefStr);
  752.                     SELF.WriteInlineProcedures(theTEView);
  753.                 END;
  754.             END;  {CASE}
  755.     END;    {TCard.WriteInterface}
  756.  
  757. {$S ARes}
  758. PROCEDURE TCard.WriteImplementation(theTEView: TMyTEView);
  759.  
  760.     VAR
  761.         aClassItem: TItem;
  762.         aString: str255;
  763.  
  764.     PROCEDURE WriteTheMethodCode(theMethodItem: TMethodItem);
  765.     
  766.         BEGIN
  767.             theMethodItem.WriteImplementation(theTEView);
  768.         END;
  769.  
  770.     BEGIN
  771.         aClassItem:= SELF.GetTheClass;
  772.         
  773.         IF fMethodList.GetSize > kNoItems THEN
  774.             BEGIN
  775.                 theTEView.WriteToMyTEView(fTextHandler.GetImplementationNoteStr(SELF));
  776.                 fMethodList.Each(WriteTheMethodCode);
  777.             END;
  778.     END;    {TCard.WriteImplementation}
  779.     
  780. {$S ARes}
  781. PROCEDURE TCard.TranslateTheCard(TheOldLanguage, TheNewLanguage:Integer);
  782.  
  783.     VAR
  784.         TheFieldList : TMyList;
  785.         TheTextHandler : TTextHandler;
  786.         TheEditView: TEditView;
  787.         ThePopUp: TPopUp;
  788.         
  789.     PROCEDURE TranslateTheItems(TheItem : TFieldItem);
  790.         BEGIN
  791.             TheTextHandler.TranslateTheItem(TheOldLanguage, TheNewLanguage, TheItem);
  792.         END; {TranslateTheItems}
  793.     
  794.  
  795. BEGIN
  796.     TheFieldList:=GetFields;
  797.     TheTextHandler:=SELF.GetTextHandler;
  798.     TheEditView:=SELF.GetEditView;
  799.     IF TheEditView<>NIL THEN
  800.         BEGIN
  801.             ThePopUp:=TPopup(TheEditView.FindSubView(kItemTypeMenuID));
  802.             TheTextHandler.SetItemTypeMenu(ThePopUp);
  803.         END;
  804.     TheFieldList.EACH(TranslateTheItems);
  805.     
  806. END; {TCard.TranslateTheCard}
  807.  
  808. {$S AWriteFile}
  809. FUNCTION  TCard.ReturnBytes: LONGINT;
  810.  
  811.     {
  812.     File structure:
  813.         the name of our class                                    (str255)
  814.         the name of our super class                        (str255)
  815.         the location of the card in its view    (VPoint)
  816.         the number of fields                                    (ArrayIndex)
  817.         each of the fields                                        (determined by them)
  818.         the number of methods                                    (ArrayIndex)
  819.         each of the methods                                        (determined by them)
  820.         the number of collaborators                        (ArrayIndex)
  821.         each of the collaborators                            (determined by them)
  822.         
  823.     }
  824.     
  825.     VAR
  826.         ourBytes:        LONGINT;
  827.         
  828.     BEGIN
  829.         {class and super class names, the location and the number of items in each list}
  830.         ourBytes:= 2 * kStringSize;
  831.         ourBytes:= ourBytes + SIZEOF(fLocation);
  832.         ourBytes:= ourBytes + (3 * SIZEOF(ArrayIndex));
  833.         
  834.         ourBytes:= ourBytes + fFieldList.ReturnBytes;
  835.         ourBytes:= ourBytes + fMethodList.ReturnBytes;
  836.         ourBytes:= ourBytes + fCollaboratorList.ReturnBytes;
  837.         
  838.         ReturnBytes:= ourBytes;
  839.     END;    {TCard.ReturnBytes}
  840.  
  841. {$S AReadFile}
  842. PROCEDURE TCard.ReadCard(aRefNum: INTEGER);
  843.  
  844.     {
  845.     File structure:
  846.         the name of our class                                    (str255)
  847.         the name of our super class                        (str255)
  848.         the location of the card in its view    (VPoint)
  849.         the number of fields                                    (ArrayIndex)
  850.         each of the fields                                        (determined by them)
  851.         the number of methods                                    (ArrayIndex)
  852.         each of the methods                                        (determined by them)
  853.         the number of collaborators                        (ArrayIndex)
  854.         each of the collaborators                            (determined by them)
  855.         
  856.     }
  857.     
  858.     VAR
  859.         aLocation:                    VPoint;
  860.         numItems,
  861.         index:                            ArrayIndex;
  862.         numBytes,
  863.         ArrayIndexSize:            LONGINT;
  864.         aFieldItem:                    TFieldItem;
  865.         aMethodItem:                TMethodItem;
  866.         aCollaboratorItem:    TCollaboratorItem;
  867.         
  868.     BEGIN
  869.         ArrayIndexSize:= SIZEOF(ArrayIndex);
  870.         
  871.         {the class name}
  872.         fClassName.ReadTheItem(aRefNum, SELF);
  873.         
  874.         {the super class name}
  875.         fSuperClass.ReadTheItem(aRefNum, SELF);
  876.         
  877.         {the location}
  878.         numBytes:= SIZEOF(aLocation);
  879.         FailOSErr(FSRead(aRefNum, numBytes, @aLocation));
  880.         SELF.SetLocation(aLocation);
  881.         
  882.         {the fields}
  883.         FailOSErr(FSRead(aRefNum, ArrayIndexSize, @numItems));
  884.         FOR index:= 1 to numItems DO
  885.             BEGIN
  886.                 NEW(aFieldItem);
  887.                 FailNIL(aFieldItem);
  888.                 aFieldItem.ReadTheItem(aRefNum, SELF);    {initialization done here}
  889.                 SELF.AddField(aFieldItem);
  890.             END;
  891.         
  892.         {the methods}
  893.         FailOSErr(FSRead(aRefNum, ArrayIndexSize, @numItems));
  894.         FOR index:= 1 to numItems DO
  895.             BEGIN
  896.                 NEW(aMethodItem);
  897.                 FailNIL(aMethodItem);
  898.                 aMethodItem.ReadTheItem(aRefNum, SELF);    {initialization done here}
  899.                 SELF.AddMethod(aMethodItem);
  900.             END;
  901.         
  902.         {the collaborators}
  903.         FailOSErr(FSRead(aRefNum, ArrayIndexSize, @numItems));
  904.         FOR index:= 1 to numItems DO
  905.             BEGIN
  906.                 NEW(aCollaboratorItem);
  907.                 FailNIL(aCollaboratorItem);
  908.                 aCollaboratorItem.ReadTheItem(aRefNum, SELF);    {initialization done here}
  909.                 SELF.AddCollaborator(aCollaboratorItem);
  910.             END;
  911.     END;    {TCard.ReadCard}
  912.  
  913. {$S AWriteFile}
  914. PROCEDURE TCard.WriteCard(aRefNum: INTEGER);
  915.  
  916.     {
  917.     File structure:
  918.         the name of our class                                    (str255)
  919.         the name of our super class                        (str255)
  920.         the location of the card in its view    (VPoint)
  921.         the number of fields                                    (ArrayIndex)
  922.         each of the fields                                        (determined by them)
  923.         the number of methods                                    (ArrayIndex)
  924.         each of the methods                                        (determined by them)
  925.         the number of collaborators                        (ArrayIndex)
  926.         each of the collaborators                            (determined by them)
  927.         
  928.     }
  929.  
  930.     VAR
  931.         theString: str255;
  932.         numBytes,
  933.         ItemSize,
  934.         ArrayIndexSize:    LONGINT;
  935.         aLocation:    VPoint;
  936.         numFields,
  937.         numMethods,
  938.         numCollaborators: ArrayIndex;
  939.         
  940.     PROCEDURE WriteIt(theItem: TItem);
  941.             
  942.         BEGIN
  943.             theItem.WriteTheItem(aRefNum);
  944.         END;    {WriteIt}
  945.         
  946.     BEGIN
  947.         ArrayIndexSize:= SIZEOF(ArrayIndex);
  948.         ItemSize:= kStringSize;
  949.         
  950.         {first our name}
  951.         theString:= fClassName.GetTheItem;
  952.         FailOSErr(FSWrite(aRefNum, ItemSize, @theString));
  953.  
  954.         {then our super class}
  955.         theString:= fSuperClass.GetTheItem;
  956.         FailOSErr(FSWrite(aRefNum, ItemSize, @theString));
  957.         
  958.         {now the location}
  959.         aLocation:= SELF.GetLocation;
  960.         numBytes:= SIZEOF(aLocation);
  961.         FailOSErr(FSWrite(aRefNum, numBytes, @aLocation));
  962.         
  963.         {get all the appropriate numbers}
  964.         numFields:= fFieldList.GetSize;
  965.         numMethods:= fMethodList.GetNumRealMethods;
  966.         numCollaborators:= fCollaboratorList.GetSize;
  967.         
  968.         {now the fields}
  969.         FailOSErr(FSWrite(aRefNum, ArrayIndexSize, @numFields));
  970.         IF numFields > 0 THEN
  971.             fFieldList.Each(WriteIt);
  972.         
  973.         {now the methods}
  974.         FailOSErr(FSWrite(aRefNum, ArrayIndexSize, @numMethods));
  975.         IF numMethods > 0 THEN
  976.             fMethodList.Each(WriteIt);
  977.         
  978.         {an finally, the collaborators}
  979.         FailOSErr(FSWrite(aRefNum, ArrayIndexSize, @numCollaborators));
  980.         IF numCollaborators > 0 THEN
  981.             fCollaboratorList.Each(WriteIt);
  982.     END;    {TCard.WriteCard}
  983.  
  984.  
  985. {$S AClose}
  986. PROCEDURE TCard.Free; OVERRIDE;
  987.  
  988.     BEGIN
  989.         fClassName.Free;
  990.         fSuperClass.Free;
  991.         fMethodList.FreeList;
  992.         fFieldList.FreeList;
  993.         fCollaboratorList.FreeList;
  994.         INHERITED Free;
  995.     END;    {TCard.Free}
  996.  
  997. {$ARes}
  998. PROCEDURE TCard.SetupFieldsMode;
  999.  
  1000. BEGIN
  1001.     fEditView.SetupFieldsMode;
  1002. END; {TCard.SetupFieldsMode}
  1003.  
  1004. {$ARes}
  1005. PROCEDURE TCard.SetupMethodsMode;
  1006.  
  1007. BEGIN
  1008.     fEditView.SetupMethodsMode;
  1009. END; {TCard.SetupMethodsMode}
  1010.  
  1011. {$ARes}
  1012. PROCEDURE TCard.SetupCollaboratorsMode;
  1013.  
  1014. BEGIN
  1015.     fEditView.SetupCollaboratorsMode;
  1016. END; {TCard.SetupCollaboratorsMode}
  1017.  
  1018. {$S AFields}
  1019. PROCEDURE TCard.Fields(PROCEDURE DoToField(
  1020.                     fieldName: Str255; fieldAddr: Ptr; fieldType: INTEGER)); OVERRIDE;
  1021.  
  1022.     BEGIN
  1023.         DoToField('TCard', NIL, bClass);
  1024.         DoToField('fClassName', @fClassName, bObject);
  1025.         DoToField('fSuperClass', @fSuperClass, bObject);
  1026.         DoToField('fDocument', @fDocument, bObject);
  1027.         DoToField('fTextHandler', @fTextHandler, bObject);
  1028.         DoToField('fDesignView', @fDesignView, bObject);
  1029.         DoToField('fEditView', @fEditView, bObject);
  1030.         DoToField('fSimpleCardView', @fSimpleCardView, bObject);
  1031.         DoToField('fLocation', @fLocation, bVPoint);
  1032.         DoToField('fFieldList', @fFieldList, bObject);
  1033.         DoToField('fMethodList', @fMethodList, bObject);
  1034.         DoToField('fCollaboratorList', @fCollaboratorList, bObject);
  1035.         INHERITED Fields(DoToField);
  1036.     END;   {TCard.Fields}